/*
 * simple.scala
 *
 * Simple commands implemented with gnuwin32 binaries.
 */
package acorn.jash.commands

import acorn.jash.{SimpleCmd}
import acorn.jash.io.stdin

class mv extends SimpleCmd

class uname extends SimpleCmd

class ls extends SimpleCmd

class svn extends SimpleCmd

class cvs extends SimpleCmd(false)

class ant extends SimpleCmd {
  override val name = "ant.bat"
}

class cat extends SimpleCmd {
  override def exec {
    if (null == in && args == Nil) in = stdin
    super.exec
  }
}

class grep extends SimpleCmd {
  override def exec {
    var pattern, file = false
    args.foreach {arg =>
      if (!(arg startsWith "-"))
        if (!pattern) pattern = true else if (pattern) file = true
                }
    if (!pattern) err putln "Please specify PATTERN.";
    else {
      if (!file && null == in) in = stdin;
      super.exec
    }
  }
}
